# -*- coding: utf-8 -*-
# @project: huawang-api20230914
# @file： randomly_generated_data.py
# @Time：2023/7/5 13:21
# @Author：lizhixiong
import random
import string
import time

from string import ascii_letters, digits
from random import sample
from common.log.log import log
import datetime
"""
造测试数据
"""


def generate_random_email(n):
    """
    生成随机的邮箱
    """
    domains = ['163_test.com', 'gmail_test.com', 'hotmail_test.com', 'yahoo_test.com', 'outlook_test.com',
               'qq_test.com']
    email = []
    for i in range(n):
        username = ''.join(random.choice(string.ascii_lowercase) for _ in range(9))
        domain = random.choice(domains)
        email.append(f"{username}@{domain}")
    return email


def generate_random_phone_number(n):
    """
    生成随机手机号
    """
    phone_numbers = []

    for _ in range(n):
        number = "162"  # 开头的手机号
        for _ in range(8):
            digit = random.randint(0, 9)
            number += str(digit)
        phone_numbers.append(number)
    return phone_numbers


def generate_random_code(n=2):
    """
    生成随机编号，默认1000以内
    """
    numbers = ''
    for i in range(n):
        numbers += ''.join(str(random.randint(100000, 999999)))
    return numbers[:-1]


def generate_random_number(n=1000):
    """
    生成随机数
    """
    return random.randint(1, n)


def generate_random_intro():
    """
    随机生成简介
    """
    adjectives = ['美味的', '独特的', '香醇的', '高质量的', '精致的', '古老的']
    types = ['红酒', '白酒', '啤酒', '威士忌', '葡萄酒', '香槟']
    origins = ['深圳', '香港', '台湾省', '中国', '江西省', '赣州市']
    descriptions = ['口感丰富且余味悠长', '独特的风味令人难以忘怀', '深受专业人士的推崇', '传承悠久的酿造工艺',
                    '具有浓郁的果香和香料味']
    intro = random.choice(adjectives) + random.choice(types) + '来自' + random.choice(origins) + '，' + random.choice(
        descriptions)
    intro += '，它是一款' + random.choice(['经典而', '高雅而', '令人愉悦且']) + random.choice(
        ['成熟的', '优雅的', '复杂的'])
    intro += random.choice(['酒品', '佳酿', '美酒']) + '，适合' + random.choice(
        ['悠闲的晚餐', '重要的庆典', '特殊的场合']) + '品尝'
    return intro


def generate_random_product_name():
    """
    随机生成酒类商品名称
    """
    adjectives = ['自动化测试的']
    types = ['红酒', '白酒', '啤酒', '威士忌', '葡萄酒', '香槟']
    nouns = ['传奇', '盛宴', '震撼', '辉煌', '梦幻', '荣耀']

    product_name = random.choice(adjectives) + random.choice(types) + random.choice(nouns) + str(
        random.randint(1000, 1999)) + '酒'
    return product_name


def generate_random_unit():
    """
    随机生成酒类商品单位
    """
    units = ['瓶', '杯', '升', '盎', '克', '罐']
    unit = random.choice(units)
    return unit


def rand_number():
    """
    时间戳后9位的随机数
    """
    return str(time.time()).replace('.', '')[-9:]


def get_rand_str(length):
    return ''.join(sample(ascii_letters + digits, k=length))


def user_descriptions():
    # 预定义的中文用户描述信息列表
    user_descriptions = [
        "友善且外向的人",
        "热爱旅行，喜欢探索新地方",
        "热衷于科技",
        "喜欢户外活动，如徒步和露营",
        "美食爱好者，喜欢尝试新的美食",
        "热爱艺术和音乐",
        "动物爱好者",
        "书虫，热衷阅读",
        "健身爱好者",
        "咖啡控",
    ]
    # 生成中文用户备注信息
    return  random.choice(user_descriptions)

def generate_random_id():
    # 随机生成地区编码
    area_code = str(random.randint(100000, 999999))

    # 随机生成出生日期
    birth_date = datetime.datetime.now().strftime("%Y%m%d")

    # 随机生成顺序号
    sequence_number = str(random.randint(100, 999))

    # 计算校验码
    id_number = area_code + birth_date + sequence_number
    return id_number


provinces = ["四川", "北京", "上海", "广东", "江苏"]
cities = ["成都", "北京", "上海", "深圳", "南京"]
districts = ["武侯", "朝阳", "浦东", "南山", "建邺"]
streets = ["人民南路", "朝阳门", "世纪大道", "深南大道", "奥体大街"]


def generate_address():
    return random.choice(provinces) + "省" + random.choice(cities) + "市" + \
        random.choice(districts) + "区" + random.choice(streets) + "街道" + str(random.randint(1, 9999)) + "号"
if __name__ == '__main__':
    print(generate_random_product_name())
    print(generate_random_unit())
    print(generate_random_intro())
    # log.info('生成随机数据为:')
    # log.info(rand_number())
    print(get_rand_str(5))
    print(user_descriptions())
    print(generate_random_id())
